/**
 *
 */
package com.wedroid.r2d2.support.response.login;

/**
 * @author lute
 *
 */
public enum LoginStatus {

    SUCCESS(200),

    SCANNED(201),

    TIMEOUT(408),

    ERROR(-1);

    private int code;

    /**
     * @param code
     */
    LoginStatus(int code) {
        this.code = code;
    }

    /**
     * @return the code
     */
    public int getCode() {
        return code;
    }

    /**
     * @param code
     * @return
     */
    public static LoginStatus codeOf(int code) {
        for (LoginStatus status : LoginStatus.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

    /**
     * @return
     */
    public boolean isSuccess() {
        return this.code == LoginStatus.SUCCESS.getCode();
    }

    /**
     * @return
     */
    public boolean isScanned() {
        return this.code == LoginStatus.SCANNED.getCode();
    }

    /**
     * @return
     */
    public boolean isTimeout() {
        return this.code == LoginStatus.TIMEOUT.getCode();
    }

}
